    var elementId;
    var url = "../project/registerAdministrator.php";

    $(document).ready(function(){
        $("#passwordForm").hide();
    });

    function showPasswordForm(){
        $("[id=passwordForm]").slideDown();
        $("[id=modify]").slideUp();
    }
    function hidePasswordForm(){
        $("[id=passwordForm]").slideUp();
        $("[id=modify]").slideDown();
    }
    function testOriginalPassword(originalPassword){
        elementId = "passVal";
        xmlHttp = GetXmlHttpObject();
        if(xmlHttp == null){
            alert("Your browser does not support AJAX!");
            return;
        }
        xmlHttp.onreadystatechange = oldPassStateChanged;
        xmlHttp.open("POST", url, true);
        var pass = 'oldPassword='+originalPassword
            +'&username='+$("#name").html();
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(pass);
    }

    function testPassword(str){
        elementId = "passVal";
        xmlHttp = GetXmlHttpObject();
        if(xmlHttp == null){
            alert("Your browser does not support AJAX!");
            return;
        }
        xmlHttp.onreadystatechange = passStateChanged;
        xmlHttp.open("POST", url, true);
        var pass = 'password='+str;
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(pass);
    }

    function oldPassStateChanged() {
        if (xmlHttp.readyState == 4){
            var response = JSON.parse(xmlHttp.responseText);
            result = '';
            if(response.length != 1){
                result = 'Incorrect password<br>';
            }
            document.getElementById('oldPasswordResponse').innerHTML = result;

        }
    }

    function passStateChanged() {
        if (xmlHttp.readyState == 4){
            var response = JSON.parse(xmlHttp.responseText);
            var result;
            var complexity = response;
            result = 'Password security: ';
            if(complexity == 1)
                result += 'very low';
            else if (complexity == 2)
                result += 'low';
            else if (complexity == 3)
                result += 'normal';
            else
                result += 'good';
            document.getElementById('passVal').innerHTML = result;

        }
    }

    function GetXmlHttpObject() {
        var xmlHttp = null;
        try {
            xmlHttp = new XMLHttpRequest();
        } catch(e){
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch(e){
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        return xmlHttp;
    }

    function updatePassword(){
        xmlHttp = GetXmlHttpObject();
        if(xmlHttp == null){
            alert("Your browser does not support AJAX!");
            return;
        }
        username = document.getElementById("name").innerHTML();
        newPassword = document.getElementById("newPassword").value();
        xmlHttp.open("POST", url, true);
        var pass = 'newPassword='+newPassword+'&username='+username;
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.send(pass);
    }